package com.vercon.common.network;


import com.vercon.common.mode.common.BaseMode;
import com.vercon.common.mode.openweather.CityBean;
import com.vercon.common.mode.openweather.OneCall;
import com.vercon.common.mode.openweather.Pollution;
import com.vercon.common.mode.weather.AirAuality;
import com.vercon.common.mode.weather.CityCodeBean;
import com.vercon.common.mode.weather.CityData;
import com.vercon.common.mode.weather.Environment;
import com.vercon.common.mode.weather.JuHeIp;
import com.vercon.common.mode.weather.LocationIpCity;
import com.vercon.common.mode.weather.NewWeatherSimpleBean;
import com.vercon.common.mode.weather.NewWeatherSimpleLifeBean;
import com.vercon.common.mode.weather.Weather;

import io.reactivex.Observable;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.Query;

/**
 * Created by csh on 2021/1/25
 * 接口
 */
public interface KillerApi {

    /**
     * 获取地址信息
     */
    String LOCATION = "geoip";
    @GET(LOCATION)
    Observable<CityBean> getLocation();

    /**
     * 获取地址信息
     */
    String LOCATION2 = "me.json";
    @GET(LOCATION2)
    Observable<LocationIpCity> getLocation2();


    //聚合天气质量
    //http://web.juhe.cn:8080/environment/air/pm?key=9cf936da26f7f5c53af15dafd42c77e7
    @GET("environment/air/pm?key=9cf936da26f7f5c53af15dafd42c77e7")
    Observable<Environment> getEnvironment(@Query("city") String cityname);


    /**
     * 聚合ip
     * @param ip
     * @return
     */
    @GET("ip/ipNewV3?key=298d1f512d243e80ce396313318bdd4e")
    Observable<JuHeIp> getJuheIp(@Query("ip") String ip);

    /**
     * 当前的空气污染数据
     */
    @GET("data/2.5/air_pollution?appid=1fdb8de0bf57c40ee9d1f0ad18640c7a")
    Observable<Pollution> getPollution(@Query("lat") double lat, @Query("lon") double lon);

    /**
     * 当前和天气预报天气数据
     */
    @GET("data/2.5/onecall?appid=1fdb8de0bf57c40ee9d1f0ad18640c7a")
    Observable<OneCall> getOneCall(@Query("lat") double lat, @Query("lon") double lon, @Query("units") String units, @Query("lang") String lang);

    /**
     * 根据城市名称获取城市信息
     */
//    @FormUrlEncoded
    @GET("admin/region/list")
    Observable<BaseMode<CityData>> getCityData(@Query("name") String cityName, @Query("page") String page,
                                               @Query("size") String size, @Query("language") String language);

    /**
     * 根据城市名称获取城市信息
     */
//    @FormUrlEncoded
    @GET("admin/regionCN/list")
    Observable<CityCodeBean> getCityCode(@Query("city") String cityName);

    /**
     * 获取聚合aqi
     *
     * @return
     */
    //@GET("environment/air/pm?key=9cf936da26f7f5c53af15dafd42c77e7")
    @GET("admin/environment")
    Observable<BaseMode<AirAuality.ResultBean>> getAqi(@Query("city") String cityName);

    //简单  根据城市查询生活指数
    //@GET("simpleWeather/life?key=6978a4c117f2e0e1e62afeb20262f5ed")
    @GET("admin/life")
    Observable<NewWeatherSimpleLifeBean> getSimpleWeatherJuHeLife(@Query("city") String cityname);

    //聚合天气
    //http://v.juhe.cn/weather/index?key=34cfb1dfc122378c20968472adfb2dcf
    //format传2
    @GET("weather/index?key=34cfb1dfc122378c20968472adfb2dcf")
    Observable<Weather> getWeatherJuHe(@Query("cityname") String cityname, @Query("format") int format);

    //简单的天气预报
    //@GET("simpleWeather/query?key=6978a4c117f2e0e1e62afeb20262f5ed")
    @GET("admin/weather/zn")
    Observable<NewWeatherSimpleBean> getSimpleWeatherJuHe(@Query("city") String cityname);

}